// src/utils/request.js
import { $fetch } from 'ofetch'

export function createRequest(baseURL) {
  return $fetch.create({
    // baseURL,
    headers: {
      'Content-Type': 'application/json',
    },
    onResponse({ response }) {
      return response._data
    },
    onResponseError({ response }) {
      console.error('API Error:', response?.status, response?.statusText)
      return Promise.reject(response || new Error('Network Error'))
    }
  })
}